import Vue from 'vue'
import Router from 'vue-router'
import ContentMain from '@/components/ContentMain'
import EditNews from '../components/EditNews/Main'
import routerPermission from './router-permission'

const LabelManager = resolve =>
  require.ensure([], () =>
    resolve(require('../components/LabelManager/Main')), 'l-g')

const UserManager = resolve =>
  require.ensure([], () =>
    resolve(require('../components/UserManager/Main')), 'l-g')

const ArticalManager = resolve =>
  require.ensure([], () =>
    resolve(require('../components/ArticalManager/Main')), 'l-g')

const Login = resolve =>
  require.ensure([], () =>
    resolve(require('../components/LoginManage/Main')), 'l-g')

Vue.use(Router)

const router = new Router({
  base: __dirname,
  mode: 'hash',
  routes: [
    { path: '/', redirect: '/EditNews' },
    {
      path: '/editnews',
      component: ContentMain,
      children: [
        {
          path: '',
          components: { dashboard: EditNews }
        }
      ]
    },
    {
      path: '/labelmanager',
      component: ContentMain,
      children: [
        {
          path: '',
          components: { dashboard: LabelManager }
        }
      ]
    },
    {
      path: '/usermanager',
      component: ContentMain,
      children: [
        {
          path: '',
          components: { dashboard: UserManager }
        }
      ]
    },
    {
      path: '/artical',
      component: ContentMain,
      children: [
        {
          path: '',
          components: { dashboard: ArticalManager }
        }
      ]
    },
    {
      path: '/login',
      component: Login
    }
  ]
})

routerPermission(router)
export default router
